/*
 * IndividualInfoSynchronizator.cpp
 *
 *  Created on: 11-01-2011
 *      Author: Przemek
 */

#include "listener/IndividualInfoSynchronizator.hpp"

IndividualInfoSynchronizator::IndividualInfoSynchronizator(Individual* individual,
		const Slider* hungerSlider, const Slider* thirstSlider, const Slider* libidoSlider,
		const Slider* lifeSlider, const Slider* angleSlider) :
	individual(individual), hungerSlider(hungerSlider), thirstSlider(thirstSlider), libidoSlider(
			libidoSlider), lifeSlider(lifeSlider), angleSlider(angleSlider)
{

}

void IndividualInfoSynchronizator::mouseReleased(const MouseListener::EventArguments&)
{
	synchronize();
}

void IndividualInfoSynchronizator::mouseDragged(const MouseListener::EventArguments&)
{
	synchronize();
}

void IndividualInfoSynchronizator::synchronize()
{
	if(World::getInstance().isRunning() == false)
	{
		State& state = individual->getState();
		state.setHungerValue(static_cast<float> (hungerSlider->getValue()));
		state.setThirstValue(static_cast<float> (thirstSlider->getValue()));
		state.setLibidoValue(static_cast<float> (libidoSlider->getValue()));
		state.setLifeValue(static_cast<float> (lifeSlider->getValue()));
		state.setLookDirection(MathUtils::getUnitCircleCoordinatesForAngle(angleSlider->getValue()));
	}
}
